<template>
  <div>
    <!-- <editor ref="editor" :value="content" @on-change="handleChange"/> -->
    <editor ref="editor" :value="formObj.content" @on-change="handleChange"/>
  </div>
</template>

<script>
import Editor from '_c/editor'
export default {
  name: 'editor_page',
  components: {
    Editor
  },
  props: {
    formObj: {
      type: Object,
      required: true
    },
    isReset: {
      type: Boolean,
      required: true,
      default: false
    }
  },
  data () {
    return {
      // content: '12312323'
    }
  },
  methods: {
    handleChange (html, text) {
      console.log('html:', html, 'text:', text)
      this.formObj.content = html
      this.$emit('editChange')
    },
    // 初始化富文本编辑框中的内容
    initContent () {
      this.$refs.editor.setHtml('')
    }
  },
  watch: { // 自己添加
    isReset (v) {
      if (v === true) {
        this.initContent()
      }
    }
  },
  mounted () {
    // 页面加载或刷新时，初始化富文本编辑框中的内容
    this.initContent()
  }
}
</script>

<style>

</style>
